import datetime
import os

from google.appengine.ext import db
from google.appengine.api import users

class Book(db.Model):
	author = db.StringProperty(multiline=False,required=True)
	name=db.StringProperty(multiline=False,required=True)
	isbn=db.StringProperty(multiline=False,required=True)
	created = db.DateTimeProperty(auto_now_add=True,required=True)
	
class BookUser(db.Model):
	user=db.UserProperty(required=True)
	
class BookOwnership(db.Model):
	book = db.ReferenceProperty(Book,required=True,collection_name='owners')
	owner=db.ReferenceProperty(BookUser,required=True,collection_name='books')
	created = db.DateTimeProperty(auto_now_add=True,required=True)
	
class Loan(db.Model):
  loaner = db.StringProperty(multiline=False,required=True)
  owner = db.ReferenceProperty(BookUser,required=True,collection_name='loans')
  book = db.ReferenceProperty(BookOwnership,required=True,collection_name='loans')
  date = db.DateTimeProperty(auto_now_add=True,required=True)